package com.xbw.service;




import java.util.List;
import java.util.Map;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.cdg.util.MD5salt;
import com.xbw.bean.Bis_Shop;
import com.xbw.bean.Bis_shop_post;
import com.xbw.bean.Sys_Menu;
import com.xbw.bean.Sys_User;
import com.xbw.mapper.UserMapper;
import com.zsy.bean.Bis_Shop_User;

@Service
public class UserServiceImpl implements UserService{
      
	   @Autowired
	   private UserMapper um;
	@Override
	public Sys_User getuser(String name) {
		return um.getuser(name);
	}
	@Override
	public List<Sys_Menu> getmenu(String rid) {
		return um.getmenu(rid);
	}
	/** 
	* TODO �������÷�����ʵ�ֹ��ܣ���ѡ��. 
	* @see com.xbw.service.UserService#selectShopUser(java.lang.String) 
	*/  
	@Override
	public Bis_Shop_User selectShopUser(String account) {
		return um.selectShopUser(account);
	}
	/** 
	* TODO �������÷�����ʵ�ֹ��ܣ���ѡ��. 
	* @see com.xbw.service.UserService#selectMenu(java.lang.String) 
	*/  
	@Override
	public List<Sys_Menu> selectMenu(String shop_user_id) {
		List<Sys_Menu> menu=um.selectMenu(shop_user_id);
		for(int i=0;i<menu.size();i++){
//			System.out.println(menu.get(i).getStatus()+" : "+menu.get(i).getMenu_id());
			if(menu.get(i).getMenu_id().equals("b5764849b97242d68e88e10551205677")){
				if(menu.get(i).getStatus().equals("0")){
					return null;
				}
				menu.remove(i);
			}
           if(menu.get(i).getStatus().equals("0")){
				menu.remove(i);
			}
		}
		return menu;
	}
	/** 
	* TODO �������÷�����ʵ�ֹ��ܣ���ѡ��.   ��������
	* @see com.xbw.service.UserService#resetpwd(java.util.Map) 
	*/  
	@Override
	public String resetpwd(Map<String, Object> map) {
		System.out.println(map);
		//  ǰ̨
		if(map.get("status").toString().equals("1")){
			int i=um.qverifier(map);
			if(i>0){ //  ��֤ͨ��
				System.out.println("qqqqqqqqq");
				map.put("pwd",MD5salt.MD5Encrtpt(map.get("name").toString(), "123") );
				System.out.println(map);
				um.qresetpwd(map);
				return "y";
			}
		}
		//  ��̨
		if(map.get("status").toString().equals("2")){
			int i=um.hverifier(map);
			if(i>0){ //  ��֤ͨ��
				System.out.println("hhhhhhhhhh");
				map.put("pwd",MD5salt.MD5Encrtpt(map.get("name").toString(), "123") );
				System.out.println(map);
				um.hresetpwd(map);
				return "y";
			}
		}
		return "n";	
	}
	/** 
	* TODO �������÷�����ʵ�ֹ��ܣ���ѡ��.  ��ѯԱ�����ڵĵ���
	* @see com.xbw.service.UserService#selectShop(java.lang.String) 
	*/  
	@Override
	public Bis_Shop selectShop(String shop_user_id) {
		return um.selectShop(shop_user_id);
	}
	
	/** 
	* TODO �������÷�����ʵ�ֹ��ܣ���ѡ��.  ��ѯ�������ڵĵ���
	* @see com.xbw.service.UserService#selectShop(java.lang.String) 
	*/  
	@Override
	public List<Bis_Shop> selectShopOwner(String shop_id) {
		return um.selectShopOwner(shop_id);
	}
	/** 
	* TODO �������÷�����ʵ�ֹ��ܣ���ѡ��.   ��ѯ�û�����ְλ
	* @see com.xbw.service.UserService#selectshopPost(java.lang.String) 
	*/  
	@Override
	public Bis_shop_post selectshopPost(String account) {
		return um.selectshopPost(account);
	}
	
	

}
